<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>使用for循环获取表单元素中文</title>
</head>

<body>
  <form name="form1">
    <tr>
      <td>销售编号：</td>
      <td><input type="text" name="num" title="销售编号"></td>
    </tr>
    <input type="button" id="change" onclick="deal(this.form); console.log(this.form)" value="提交">
    <input type="reset" value="重置" />
  </form>

  <script>
    function deal(form) {
      const len = form.length;
      for (let i = 0; i < len; i++) {
        console.log(i + form.elements[i].value)
        if (!form.elements[i].value) {
          alert(form[i].title + form.elements[i].title + '不能为空');
        }
      }
    }
  </script>
</body>

</html>